package itsense.component;

import com.google.gwt.user.client.ui.Image;
import com.smartgwt.client.types.Alignment;
import com.smartgwt.client.widgets.IButton;
import com.smartgwt.client.widgets.Img;
import com.smartgwt.client.widgets.Label;
import com.smartgwt.client.widgets.events.MouseOutEvent;
import com.smartgwt.client.widgets.events.MouseOutHandler;
import com.smartgwt.client.widgets.events.MouseOverEvent;
import com.smartgwt.client.widgets.events.MouseOverHandler;
import com.smartgwt.client.widgets.layout.HStack;
import com.smartgwt.client.widgets.layout.VStack;

public class ITSButton extends IButton {
	private Img img;
	private Label label;
	public ITSButton(String imagePath, String title) {
		img = new Img(imagePath, 32, 32);
		label = new Label(title);
		label.setAlign(Alignment.CENTER);
		setBackgroundColor("blue");
		init();
	}
	
	private void init(){
		setWidth(48);
		setHeight(48);
		HStack hStack1 = new HStack();
		hStack1.setWidth100();
		hStack1.setHeight("80%");
		hStack1.setAlign(Alignment.CENTER);
		hStack1.addMember(img);
		
		HStack hStack2 = new HStack();
		hStack2.setWidth100();
		hStack2.setHeight("20%");
		hStack2.setAlign(Alignment.CENTER);
		hStack2.addMember(label);
		
		VStack vStack = new VStack();
		vStack.setAlign(Alignment.CENTER);
		vStack.setWidth100();
		vStack.setHeight100();
		vStack.addMember(hStack1);
		vStack.addMember(hStack2);
		addChild(vStack);
		
		addMouseOverHandler(new MouseOverHandler() {
			public void onMouseOver(MouseOverEvent event) {
				setBackgroundColor("yellow");
				
			}
		});
		
		addMouseOutHandler(new MouseOutHandler() {
			
			public void onMouseOut(MouseOutEvent event) {
				setBackgroundColor("blue");
			}
		});
	}
	
	

}

